<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <form id="login-form" action="#">
        <label>账号：<input id="usernameIpt" type="text" name="usernameIpt"></label>
        <label>密码：<input id="password" type="text" name="username"></label>
        <button id="button" type="submit">登录</button>
    </form>
</head>
<body>
<script>
    let loginForm=document.querySelector('#login-form')
    let usernameIpt=document.querySelector('#usernameIpt');
    let password=document.querySelector('#password');
    let button=document.querySelector('#button');

    usernameIpt.focus();
   loginForm.onsubmit=()=>{
        if (''===usernameIpt.value||null===usernameIpt.value){
            alert('账号不能为空！');
            usernameIpt.focus();
            return false;
        }
        if (''===password.value||null===password.value){
            alert('密码不能为空！');
            password.focus();
            return false;
        }

    }

</script>
</body>
</html>